package demo3;

import java.util.Scanner;

public class Practise6 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int len = in.nextInt();
        int[] arr = new int[len];
        boolean flag = true;
        for (int i = 0; i < len; i++) {
            arr[i] = in.nextInt();
        }
        for (int i = 0; i < len; i++) {
            if(i + 1 != arr[arr[i] - 1]) {
                System.out.printf("NO");
                flag = false;
                break;
            }
        }
        if(flag) {
            System.out.printf("YES");
        }
    }
}
